<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
        html, body {
            background-color: #f8f8f8;
        }
        .main {
            background-color: #fff;
        }
        .main ul li {
            border-bottom: 2px solid #f8f8f8;
        }
        .main ul li:last-child {
            border-bottom: none;
        }
        .box {
            padding: 15px;
        }
        .boxt {
            display: -webkit-box;
            display: -webkit-flex;
            align-items: center;
            margin-bottom: 10px;
        }
        .boxt .boxt_l .img_box {
            width: 45px;
            height: 45px;
            overflow: hidden;           
            border-radius: 50%;
        }
        .boxt .boxt_l .img_box img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .boxt .boxt_r {
            width: 0;
            flex: 1;
            -webkit-flex: 1;
            box-flex: 1;
            -webkit-box-flex: 1;
            padding: 0 10px;
        }
        .boxt .boxt_r .title {
            font-size: 15px;
            color: #333;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin-bottom: 5px;
        }
        .boxt .boxt_r .time {
            color: #999;
            font-size: 12px;
        }
        .boxt .boxt_r img {
            height: 13px;
            display: block;
        }
        .boxc {
            color: #333;
            font-size: 15px;
            margin-bottom: 10px;
        }
        .evaluate_num_box {
            font-size: 14px;
            color: #333;
            display: -webkit-box;
            -webkit-box-align: center;
            margin-bottom: 5px;
        }
        .evaluate_num_box:last-child {
            margin-bottom: 0;
        }
        .evaluate_num_box .evaluate_div {
            display: -webkit-box;
            display: -webkit-flex;
            align-items: center;
            margin-left: 10px;
        }
        .evaluate_num_box .evaluate_div .evaluate_icon {
            overflow: hidden;
            margin-right: 7px;
        }
        .evaluate_num_box .evaluate_div .evaluate_icon img {
            height: 17px;
            float: left;
            margin-right: 7px;
        }
        .evaluate_num_box .evaluate_div .evaluate_icon img:last-child {
            margin-right: 0;
        }
    </style>
</head>
<body>
    <div class="main">
        <ul id="commentC">
            <!-- <li>
                <div class="box">
                    <div class="boxt">
                        <div class="boxt_l">
                            <div class="img_box">
                                <img src="../image/temp/1.png">
                            </div>
                        </div>
                        <div class="boxt_r">
                            <div class="title">商家名称</div>
                            <div class="time">2017-09-08 12:42:14</div>
                        </div>
                    </div>
                    <div class="boxc">该用户没有评论内容</div>
                    <div class="boxb">
                        <div class="evaluate_num_box">
                            服务态度
                            <div class="evaluate_div">
                                <div class="evaluate_icon">
                                    <img src="../image/evaluate_on.png">
                                    <img src="../image/evaluate_on.png">
                                    <img src="../image/evaluate_on.png">
                                    <img src="../image/evaluate_on.png">
                                    <img src="../image/evaluate_off.png">
                                </div>
                            </div>
                        </div>
                        <div class="evaluate_num_box">
                            配送速度
                            <div class="evaluate_div">
                                <div class="evaluate_icon">
                                    <img src="../image/evaluate_on.png">
                                    <img src="../image/evaluate_on.png">
                                    <img src="../image/evaluate_on.png">
                                    <img src="../image/evaluate_on.png">
                                    <img src="../image/evaluate_off.png">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </li> -->
        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script id="commentL" type="text/x-dot-template">
    {{ for (var i = 0; i < it.length; i++) { }}
        <li>
            <div class="box">
                <div class="boxt">
                    <div class="boxt_l">
                        <div class="img_box">
                            <img src="{{=formatHeadImg(it[i].img)}}">
                        </div>
                    </div>
                    <div class="boxt_r">
                        <div class="title">{{=it[i].nickname}}</div>
                        <div class="time">{{=it[i].create_time}}</div>
                    </div>
                </div>
                <div class="boxc">
                    {{if(it[i]['content']){ }}
                        {{=it[i].content}}
                    {{ } else{ }}
                        该用户没有评论内容
                    {{ }; }}
                </div>
                <div class="boxb">
                    <div class="evaluate_num_box">
                        服务态度
                        <div class="evaluate_div">
                            <div class="evaluate_icon">
                                {{ for (var j = 1; j < 6; j++) { }}
                                    {{if(it[i]['service_score'] < j){ }}
                                        <img src="../image/evaluate_off.png">
                                    {{ } else{ }}
                                        <img src="../image/evaluate_on.png">
                                    {{ }; }}
                                {{ }; }}
                            </div>
                        </div>
                    </div>
                    <div class="evaluate_num_box">
                        配送速度
                        <div class="evaluate_div">
                            <div class="evaluate_icon">
                                {{ for (var j = 1; j < 6; j++) { }}
                                    {{if(it[i]['delivery_score'] < j){ }}
                                        <img src="../image/evaluate_off.png">
                                    {{ } else{ }}
                                        <img src="../image/evaluate_on.png">
                                    {{ }; }}
                                {{ }; }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </li>
    {{ }; }}
</script>
<script type="text/javascript">
    
    var p = 1; //默认第一页
    var canLoad = false; // 默认不可上拉加载更多
    
    apiready = function(){
        staffData = $api.getStorage('staff_data');
        getOrderList();

        // 下拉刷新
        api.setCustomRefreshHeaderInfo({
            bgColor: '#f8f8f8',
            loadAnimInterval:60,
            image: {
               pull: pullArr,
               load: loadArr
            }
        }, function(ret, err) {
            p = 1;
            canLoad = false;
            getOrderList(1);
        });

        // 上拉加载
        api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold:0            //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function(ret, err){
            if(canLoad == true){
                canLoad = false;
                var _dom = $api.byId('commentC');
                setLoadingData(_dom);
                getOrderList(2);
            }
        });

    };

    function getOrderList(t) {
        if(t != 2){
            openLoading();
        }
        api.ajax({
            url: rootPath + '/api/staff/get_staff_comment',
            method: 'get',
            cache: true,
            data: {
                values: {
                    staff_id: staffData.id,
                    staff_token: staffData.token,
                    p: p,
                },
            }
        }, function(ret, err) {
            if (ret && ret.status == 200) {
                if(t == 2){
                    appendDotData(ret.data,'commentL','commentC',true);
                }else{
                    setDotData(ret.data,'commentL','commentC',true);
                }
                if(ret.data.length == 10){
                    canLoad = true;
                    p++;
                }
                closeLoading();
            } else {
                if(p == 1){
                    // 首次获取就无订单
                    var _dom = $api.byId('commentC');
                    setWithoutData(_dom,'暂无数据','#f8f8f8');
                }
                canLoad = false;
                closeLoading();
            }
            if(t == 1){
                api.refreshHeaderLoadDone();
            }
            hideLoadingData();
        });
    }


</script>
</html>